<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="Keywords" content="">
	<meta name="description" content="">
	<link rel="shortcut icon" type="image/x-icon" href="/static/images/favicon.ico">
	<!--公共部分-->
	<link href="/static/www/css/layout.css" type="text/css" rel="stylesheet" />
	<script src="/static/public/jquery-1.11.1.min.js" type="text/javascript"></script>
	<!--私有部分-->
	<link href="/static/www/css/default.style.css" type="text/css" rel="stylesheet" />
  <script src="/static/public/layer/layer.js" type="text/javascript"></script>

	<title>登录 </title>

	<script>
	$(function () {
	
		//登录
		$("#btn_submit").click(function () {
			var phone = $("#phone").val();
			var vcode = $("#vcode").val();
			var pwd = $("#pwd").val();
			if(phone==""){
				layer.tips('请输入手机号', '#phone', {time: 5000});
				return;
			}
			if(vcode==""){
				layer.tips('请输入验证码', '#vcode', {time: 5000});
				return;
			}
			if(pwd==""){
				layer.tips('请输入密码', '#pwd', {time: 5000});
				return;
			}
			$.post('/reg/iframe',{'phone':phone,'vcode':vcode,'pwd':pwd},function (res) {
				var obj = eval('(' + res + ')');
				if(obj.result==0){
					alert("注册成功");
					//注册成功
					parent.login_success();
				}else{
					if(obj.result == 404){
						layer.tips(obj.msg, '#phone', {time: 5000});
					}else if(obj.result == 400) {
						layer.tips(obj.msg, '#pwd', {time: 5000});
					}else {
						layer.msg(obj.msg,  {time: 5000});
					}

				}
				// alert(obj.result);
			});
		});


	})
	</script>
</head>
<body>
<div class="registerMain">
    <div class="mt"><a href="/login/iframe">登录</a><span class="fs20">注册</span></div>
    <div class="mc" id="login_div">
        <div class="formLoginRegister">
        
            <ul>
                <li class="iFrTit"><span name="fr_tit"><img src="/static/www/images/i_login.png"></span>
                <input class="text" id="phone" name="phone" maxlength="11" type="text" placeholder="请输入手机号码">
                <a name="fr_tip" href="javascript:;" style="color: red" class="r send-msg" hasClick="1">获取验证码</a>
                </li>
                <li class="iFrTit"><span name="fr_tit"><img src="/static/www/images/i_login.png"></span>
                <input class="text"  maxlength="4" name="vcode" id="vcode" type="text" placeholder="验证码">
                
                </li>
                <li class="iFrTit"><span name="fr_tit"><img src="/static/www/images/i_regis.png"></span>
                <input class="text" id="pwd" name="pwd" type="password" value="" maxlength="12" placeholder="请输入密码，6-12位">
                
                </li>
            </ul>
            
            <div class="p-t10"><a href="javascript:;" id="btn_submit" class="b-1aa3fa btn u2 fs20">注册</a></div>
	        <div class="c oh h20 tac">
				<{if isset($err_msg)}><{$err_msg}><{/if}>
			</div>
        </div>
    </div>

</div>
<script type="text/javascript">
	$(function ($) {
		var countdown = 5;
		//发送短信验证码
		$(".send-msg").click(function(){
			var obj = $(this);
			var linkPhone = $("#phone").val();
			if(linkPhone==""){
				alert("请填写手机号");
				$("#phone").focus();
				return;
			}else{
				var hasClick = $(obj).attr("hasclick");
				if (hasClick == 1) {
//                    alert("开始获取验证码");
					countdown = 60;
					$.ajax({
						url:"/reg/reg_msg/"+linkPhone,
						type:"post",
						dataType:"json",
						success:function(res){
							if(res.code==201){
								$("#pwd_li").remove();
								settime(obj);
							} else if (res.code == 200) {
								alert("短信发送成功！请注意查收！");
								settime(obj);
							}else{
								alert(res.msg);
							}
						}
					});
				}
			}

		});


		function settime(val) {
			if (countdown == 0) {
				//                $(val).removeAttribute("disabled");
				$(val).attr("hasclick", "1");
				$(val).text("免费获取验证码");
			} else {
				$(val).attr("hasclick", "0");
				//                $(val).("disabled", true);
				$(val).text("重新发送(" + countdown + ")");
				countdown--;
				setTimeout(function () {
					settime(val)
				}, 1000);
			}
		}

	});
</script>
</body>
</html>
